package com.codingman.thymeleafdemo1;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.WebContext;

public class demo7Servlet extends HttpServlet {
	@Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		List<Employee> emps = new ArrayList<Employee>();
		emps.add(new Employee(101, "Ann", 100.00));
		emps.add(new Employee(102, "Bob", 200.00));
		
		WebContext ctx = new WebContext(request, response, request.getServletContext());
		ctx.setVariable("employees", emps);
		
		TemplateEngine engine = ThymeleafUtil.getTemplateEngine(request.getServletContext());
		engine.process("demo7", ctx, response.getWriter());
	}
}
